home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NOVA - For the NeXT Workstation
/
NOVA - For the NeXT Workstation.iso
/
Documents
/
NeXTAnswers
/
mathematica.359
< prev
next >
Wrap
Text File
|
1992-02-06
|
1KB
|
59 lines
Mathematica communications functions
Q: How do I communicate with Mathametica through installed programs?
A: This application requires mathlink.[hc], given in QA360, to run correctly.
#include "mathlink.h"
#include <string.h>
main()
{
int BitAnd(), CheckSum();
char c1[40];
/*
** notify Mathematica that we are going to link code into it
*/
printf("i got here \n");
MathInit();
/*
** install our new procedures
*/
strcpy(c1,"x_Integer");
strcat(c1,"y_Integer");
MathInstall(BitAnd,"BitAnd","int","x_Integer,y_Integer","int, int");
MathInstall(CheckSum,"CheckSum","int","x_String \0","char *");
/*
** give usage messages for them
*/
MathExec("BitAnd::usage = \"BitAnd[x,y] computes the bitwise logical AND of the (machine-length) integers x and y.\"");
MathExec("CheckSum::usage = \"CheckSum[x] computes a checksum for the string x.\"");
/*
** relinquish control to Mathematica, and wait to be called
*/
MathStart();
}
int BitAnd(x,y)
{
return(x&y);
}
int CheckSum(x)
char *x;
{
register int n,i;
n = 0;
while ( i = *x++ ) n = (n+i) % 256;
return(n);
}
QA359
Valid for 1.0
Not checked yet for 2.0